﻿using LiteBlog.Common.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LiteBlog.Controllers.Filters
{
    public class PageExceptionFilter : FilterAttribute, IExceptionFilter
    {
        public void OnException(ExceptionContext filterContext)
        {
            if (filterContext.ExceptionHandled)
                return;

            if (filterContext.Exception != null)
                Logger.Log("ViewHandleErrorAttribute", filterContext.Exception);

                        
            var controller = filterContext.Controller as BaseController;
            filterContext.Result = controller.ErrorPage(filterContext.Exception);
            filterContext.ExceptionHandled = true;
        }
    }
}